Optimal. Leaf size=103 \[ -\frac {\tanh ^{-1}(\cos (c+d x))}{a^2 d}+\frac {\sqrt {b} (3 a+2 b) \tanh ^{-1}\left (\frac {\sqrt {b} \cos (c+d x)}{\sqrt {a+b}}\right )}{2 a^2 (a+b)^{3/2} d}+\frac {b \cos (c+d x)}{2 a (a+b) d \left (a+b-b \cos ^2(c+d x)\right )} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.08, antiderivative size = 103, normalized size of antiderivative = 1.00, number of steps
used = 5, number of rules used = 5, integrand size = 21, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.238, Rules used = {3265, 425, 536,
212, 214} \begin {gather*} \frac {\sqrt {b} (3 a+2 b) \tanh ^{-1}\left (\frac {\sqrt {b} \cos (c+d x)}{\sqrt {a+b}}\right )}{2 a^2 d (a+b)^{3/2}}-\frac {\tanh ^{-1}(\cos (c+d x))}{a^2 d}+\frac {b \cos (c+d x)}{2 a d (a+b) \left (a-b \cos ^2(c+d x)+b\right )} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 212
Rule 214
Rule 425
Rule 536
Rule 3265
Rubi steps
\begin {align*} \int \frac {\csc (c+d x)}{\left (a+b \sin ^2(c+d x)\right )^2} \, dx &=-\frac {\text {Subst}\left (\int \frac {1}{\left (1-x^2\right ) \left (a+b-b x^2\right )^2} \, dx,x,\cos (c+d x)\right )}{d}\\ &=\frac {b \cos (c+d x)}{2 a (a+b) d \left (a+b-b \cos ^2(c+d x)\right )}+\frac {\text {Subst}\left (\int \frac {-2 a-b-b x^2}{\left (1-x^2\right ) \left (a+b-b x^2\right )} \, dx,x,\cos (c+d x)\right )}{2 a (a+b) d}\\ &=\frac {b \cos (c+d x)}{2 a (a+b) d \left (a+b-b \cos ^2(c+d x)\right )}-\frac {\text {Subst}\left (\int \frac {1}{1-x^2} \, dx,x,\cos (c+d x)\right )}{a^2 d}+\frac {(b (3 a+2 b)) \text {Subst}\left (\int \frac {1}{a+b-b x^2} \, dx,x,\cos (c+d x)\right )}{2 a^2 (a+b) d}\\ &=-\frac {\tanh ^{-1}(\cos (c+d x))}{a^2 d}+\frac {\sqrt {b} (3 a+2 b) \tanh ^{-1}\left (\frac {\sqrt {b} \cos (c+d x)}{\sqrt {a+b}}\right )}{2 a^2 (a+b)^{3/2} d}+\frac {b \cos (c+d x)}{2 a (a+b) d \left (a+b-b \cos ^2(c+d x)\right )}\\ \end {align*}
________________________________________________________________________________________
Mathematica [C] Result contains complex when optimal does not.
time = 0.54, size = 194, normalized size = 1.88 \begin {gather*} \frac {\frac {\sqrt {b} (3 a+2 b) \tan ^{-1}\left (\frac {\sqrt {b}-i \sqrt {a} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {-a-b}}\right )}{(-a-b)^{3/2}}+\frac {\sqrt {b} (3 a+2 b) \tan ^{-1}\left (\frac {\sqrt {b}+i \sqrt {a} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {-a-b}}\right )}{(-a-b)^{3/2}}+2 \left (\frac {a b \cos (c+d x)}{(a+b) (2 a+b-b \cos (2 (c+d x)))}-\log \left (\cos \left (\frac {1}{2} (c+d x)\right )\right )+\log \left (\sin \left (\frac {1}{2} (c+d x)\right )\right )\right )}{2 a^2 d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.41, size = 107, normalized size = 1.04
method | result | size |
derivativedivides | \(\frac {-\frac {\ln \left (1+\cos \left (d x +c \right )\right )}{2 a^{2}}+\frac {\ln \left (\cos \left (d x +c \right )-1\right )}{2 a^{2}}+\frac {b \left (\frac {a \cos \left (d x +c \right )}{2 \left (a +b \right ) \left (a +b -b \left (\cos ^{2}\left (d x +c \right )\right )\right )}+\frac {\left (3 a +2 b \right ) \arctanh \left (\frac {b \cos \left (d x +c \right )}{\sqrt {\left (a +b \right ) b}}\right )}{2 \left (a +b \right ) \sqrt {\left (a +b \right ) b}}\right )}{a^{2}}}{d}\) | \(107\) |
default | \(\frac {-\frac {\ln \left (1+\cos \left (d x +c \right )\right )}{2 a^{2}}+\frac {\ln \left (\cos \left (d x +c \right )-1\right )}{2 a^{2}}+\frac {b \left (\frac {a \cos \left (d x +c \right )}{2 \left (a +b \right ) \left (a +b -b \left (\cos ^{2}\left (d x +c \right )\right )\right )}+\frac {\left (3 a +2 b \right ) \arctanh \left (\frac {b \cos \left (d x +c \right )}{\sqrt {\left (a +b \right ) b}}\right )}{2 \left (a +b \right ) \sqrt {\left (a +b \right ) b}}\right )}{a^{2}}}{d}\) | \(107\) |
risch | \(-\frac {b \left ({\mathrm e}^{3 i \left (d x +c \right )}+{\mathrm e}^{i \left (d x +c \right )}\right )}{a \left (a +b \right ) d \left (b \,{\mathrm e}^{4 i \left (d x +c \right )}-4 a \,{\mathrm e}^{2 i \left (d x +c \right )}-2 b \,{\mathrm e}^{2 i \left (d x +c \right )}+b \right )}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-1\right )}{a^{2} d}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+1\right )}{a^{2} d}+\frac {3 i \sqrt {-\left (a +b \right ) b}\, \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+\frac {2 i \sqrt {-\left (a +b \right ) b}\, {\mathrm e}^{i \left (d x +c \right )}}{b}+1\right )}{4 \left (a +b \right )^{2} d a}+\frac {i \sqrt {-\left (a +b \right ) b}\, \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+\frac {2 i \sqrt {-\left (a +b \right ) b}\, {\mathrm e}^{i \left (d x +c \right )}}{b}+1\right ) b}{2 \left (a +b \right )^{2} d \,a^{2}}-\frac {3 i \sqrt {-\left (a +b \right ) b}\, \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-\frac {2 i \sqrt {-\left (a +b \right ) b}\, {\mathrm e}^{i \left (d x +c \right )}}{b}+1\right )}{4 \left (a +b \right )^{2} d a}-\frac {i \sqrt {-\left (a +b \right ) b}\, \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-\frac {2 i \sqrt {-\left (a +b \right ) b}\, {\mathrm e}^{i \left (d x +c \right )}}{b}+1\right ) b}{2 \left (a +b \right )^{2} d \,a^{2}}\) | \(343\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 0.50, size = 149, normalized size = 1.45 \begin {gather*} \frac {\frac {2 \, b \cos \left (d x + c\right )}{a^{3} + 2 \, a^{2} b + a b^{2} - {\left (a^{2} b + a b^{2}\right )} \cos \left (d x + c\right )^{2}} - \frac {{\left (3 \, a b + 2 \, b^{2}\right )} \log \left (\frac {b \cos \left (d x + c\right ) - \sqrt {{\left (a + b\right )} b}}{b \cos \left (d x + c\right ) + \sqrt {{\left (a + b\right )} b}}\right )}{{\left (a^{3} + a^{2} b\right )} \sqrt {{\left (a + b\right )} b}} - \frac {2 \, \log \left (\cos \left (d x + c\right ) + 1\right )}{a^{2}} + \frac {2 \, \log \left (\cos \left (d x + c\right ) - 1\right )}{a^{2}}}{4 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 208 vs.
\(2 (94) = 188\).
time = 0.46, size = 455, normalized size = 4.42 \begin {gather*} \left [-\frac {2 \, a b \cos \left (d x + c\right ) - {\left ({\left (3 \, a b + 2 \, b^{2}\right )} \cos \left (d x + c\right )^{2} - 3 \, a^{2} - 5 \, a b - 2 \, b^{2}\right )} \sqrt {\frac {b}{a + b}} \log \left (\frac {b \cos \left (d x + c\right )^{2} + 2 \, {\left (a + b\right )} \sqrt {\frac {b}{a + b}} \cos \left (d x + c\right ) + a + b}{b \cos \left (d x + c\right )^{2} - a - b}\right ) + 2 \, {\left ({\left (a b + b^{2}\right )} \cos \left (d x + c\right )^{2} - a^{2} - 2 \, a b - b^{2}\right )} \log \left (\frac {1}{2} \, \cos \left (d x + c\right ) + \frac {1}{2}\right ) - 2 \, {\left ({\left (a b + b^{2}\right )} \cos \left (d x + c\right )^{2} - a^{2} - 2 \, a b - b^{2}\right )} \log \left (-\frac {1}{2} \, \cos \left (d x + c\right ) + \frac {1}{2}\right )}{4 \, {\left ({\left (a^{3} b + a^{2} b^{2}\right )} d \cos \left (d x + c\right )^{2} - {\left (a^{4} + 2 \, a^{3} b + a^{2} b^{2}\right )} d\right )}}, -\frac {a b \cos \left (d x + c\right ) + {\left ({\left (3 \, a b + 2 \, b^{2}\right )} \cos \left (d x + c\right )^{2} - 3 \, a^{2} - 5 \, a b - 2 \, b^{2}\right )} \sqrt {-\frac {b}{a + b}} \arctan \left (\sqrt {-\frac {b}{a + b}} \cos \left (d x + c\right )\right ) + {\left ({\left (a b + b^{2}\right )} \cos \left (d x + c\right )^{2} - a^{2} - 2 \, a b - b^{2}\right )} \log \left (\frac {1}{2} \, \cos \left (d x + c\right ) + \frac {1}{2}\right ) - {\left ({\left (a b + b^{2}\right )} \cos \left (d x + c\right )^{2} - a^{2} - 2 \, a b - b^{2}\right )} \log \left (-\frac {1}{2} \, \cos \left (d x + c\right ) + \frac {1}{2}\right )}{2 \, {\left ({\left (a^{3} b + a^{2} b^{2}\right )} d \cos \left (d x + c\right )^{2} - {\left (a^{4} + 2 \, a^{3} b + a^{2} b^{2}\right )} d\right )}}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \frac {\csc {\left (c + d x \right )}}{\left (a + b \sin ^{2}{\left (c + d x \right )}\right )^{2}}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 246 vs.
\(2 (94) = 188\).
time = 0.49, size = 246, normalized size = 2.39 \begin {gather*} -\frac {\frac {{\left (3 \, a b + 2 \, b^{2}\right )} \arctan \left (\frac {b \cos \left (d x + c\right ) + a + b}{\sqrt {-a b - b^{2}} \cos \left (d x + c\right ) + \sqrt {-a b - b^{2}}}\right )}{{\left (a^{3} + a^{2} b\right )} \sqrt {-a b - b^{2}}} - \frac {2 \, {\left (a b - \frac {a b {\left (\cos \left (d x + c\right ) - 1\right )}}{\cos \left (d x + c\right ) + 1} - \frac {2 \, b^{2} {\left (\cos \left (d x + c\right ) - 1\right )}}{\cos \left (d x + c\right ) + 1}\right )}}{{\left (a^{3} + a^{2} b\right )} {\left (a - \frac {2 \, a {\left (\cos \left (d x + c\right ) - 1\right )}}{\cos \left (d x + c\right ) + 1} - \frac {4 \, b {\left (\cos \left (d x + c\right ) - 1\right )}}{\cos \left (d x + c\right ) + 1} + \frac {a {\left (\cos \left (d x + c\right ) - 1\right )}^{2}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{2}}\right )}} - \frac {\log \left (\frac {{\left | -\cos \left (d x + c\right ) + 1 \right |}}{{\left | \cos \left (d x + c\right ) + 1 \right |}}\right )}{a^{2}}}{2 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 14.63, size = 2039, normalized size = 19.80 \begin {gather*} \frac {b\,\cos \left (c+d\,x\right )}{2\,a\,d\,\left (a+b\right )\,\left (-b\,{\cos \left (c+d\,x\right )}^2+a+b\right )}-\frac {\mathrm {atan}\left (\frac {\frac {\frac {\left (\frac {4\,a^6\,b^2+6\,a^5\,b^3+2\,a^4\,b^4}{2\,\left (a^5+2\,a^4\,b+a^3\,b^2\right )}-\frac {\cos \left (c+d\,x\right )\,\left (16\,a^7\,b^2+64\,a^6\,b^3+80\,a^5\,b^4+32\,a^4\,b^5\right )}{8\,a^2\,\left (a^4+2\,a^3\,b+a^2\,b^2\right )}\right )\,1{}\mathrm {i}}{2\,a^2}+\frac {\cos \left (c+d\,x\right )\,\left (13\,a^2\,b^3+20\,a\,b^4+8\,b^5\right )\,1{}\mathrm {i}}{4\,\left (a^4+2\,a^3\,b+a^2\,b^2\right )}}{a^2}-\frac {\frac {\left (\frac {4\,a^6\,b^2+6\,a^5\,b^3+2\,a^4\,b^4}{2\,\left (a^5+2\,a^4\,b+a^3\,b^2\right )}+\frac {\cos \left (c+d\,x\right )\,\left (16\,a^7\,b^2+64\,a^6\,b^3+80\,a^5\,b^4+32\,a^4\,b^5\right )}{8\,a^2\,\left (a^4+2\,a^3\,b+a^2\,b^2\right )}\right )\,1{}\mathrm {i}}{2\,a^2}-\frac {\cos \left (c+d\,x\right )\,\left (13\,a^2\,b^3+20\,a\,b^4+8\,b^5\right )\,1{}\mathrm {i}}{4\,\left (a^4+2\,a^3\,b+a^2\,b^2\right )}}{a^2}}{\frac {\frac {\frac {4\,a^6\,b^2+6\,a^5\,b^3+2\,a^4\,b^4}{2\,\left (a^5+2\,a^4\,b+a^3\,b^2\right )}-\frac {\cos \left (c+d\,x\right )\,\left (16\,a^7\,b^2+64\,a^6\,b^3+80\,a^5\,b^4+32\,a^4\,b^5\right )}{8\,a^2\,\left (a^4+2\,a^3\,b+a^2\,b^2\right )}}{2\,a^2}+\frac {\cos \left (c+d\,x\right )\,\left (13\,a^2\,b^3+20\,a\,b^4+8\,b^5\right )}{4\,\left (a^4+2\,a^3\,b+a^2\,b^2\right )}}{a^2}+\frac {\frac {\frac {4\,a^6\,b^2+6\,a^5\,b^3+2\,a^4\,b^4}{2\,\left (a^5+2\,a^4\,b+a^3\,b^2\right )}+\frac {\cos \left (c+d\,x\right )\,\left (16\,a^7\,b^2+64\,a^6\,b^3+80\,a^5\,b^4+32\,a^4\,b^5\right )}{8\,a^2\,\left (a^4+2\,a^3\,b+a^2\,b^2\right )}}{2\,a^2}-\frac {\cos \left (c+d\,x\right )\,\left (13\,a^2\,b^3+20\,a\,b^4+8\,b^5\right )}{4\,\left (a^4+2\,a^3\,b+a^2\,b^2\right )}}{a^2}-\frac {b^4+\frac {3\,a\,b^3}{2}}{a^5+2\,a^4\,b+a^3\,b^2}}\right )\,1{}\mathrm {i}}{a^2\,d}+\frac {\mathrm {atan}\left (\frac {\frac {\left (\frac {\cos \left (c+d\,x\right )\,\left (13\,a^2\,b^3+20\,a\,b^4+8\,b^5\right )}{2\,\left (a^4+2\,a^3\,b+a^2\,b^2\right )}+\frac {\sqrt {b\,{\left (a+b\right )}^3}\,\left (\frac {4\,a^6\,b^2+6\,a^5\,b^3+2\,a^4\,b^4}{a^5+2\,a^4\,b+a^3\,b^2}-\frac {\cos \left (c+d\,x\right )\,\sqrt {b\,{\left (a+b\right )}^3}\,\left (3\,a+2\,b\right )\,\left (16\,a^7\,b^2+64\,a^6\,b^3+80\,a^5\,b^4+32\,a^4\,b^5\right )}{8\,\left (a^4+2\,a^3\,b+a^2\,b^2\right )\,\left (a^5+3\,a^4\,b+3\,a^3\,b^2+a^2\,b^3\right )}\right )\,\left (3\,a+2\,b\right )}{4\,\left (a^5+3\,a^4\,b+3\,a^3\,b^2+a^2\,b^3\right )}\right )\,\sqrt {b\,{\left (a+b\right )}^3}\,\left (3\,a+2\,b\right )\,1{}\mathrm {i}}{4\,\left (a^5+3\,a^4\,b+3\,a^3\,b^2+a^2\,b^3\right )}+\frac {\left (\frac {\cos \left (c+d\,x\right )\,\left (13\,a^2\,b^3+20\,a\,b^4+8\,b^5\right )}{2\,\left (a^4+2\,a^3\,b+a^2\,b^2\right )}-\frac {\sqrt {b\,{\left (a+b\right )}^3}\,\left (\frac {4\,a^6\,b^2+6\,a^5\,b^3+2\,a^4\,b^4}{a^5+2\,a^4\,b+a^3\,b^2}+\frac {\cos \left (c+d\,x\right )\,\sqrt {b\,{\left (a+b\right )}^3}\,\left (3\,a+2\,b\right )\,\left (16\,a^7\,b^2+64\,a^6\,b^3+80\,a^5\,b^4+32\,a^4\,b^5\right )}{8\,\left (a^4+2\,a^3\,b+a^2\,b^2\right )\,\left (a^5+3\,a^4\,b+3\,a^3\,b^2+a^2\,b^3\right )}\right )\,\left (3\,a+2\,b\right )}{4\,\left (a^5+3\,a^4\,b+3\,a^3\,b^2+a^2\,b^3\right )}\right )\,\sqrt {b\,{\left (a+b\right )}^3}\,\left (3\,a+2\,b\right )\,1{}\mathrm {i}}{4\,\left (a^5+3\,a^4\,b+3\,a^3\,b^2+a^2\,b^3\right )}}{\frac {b^4+\frac {3\,a\,b^3}{2}}{a^5+2\,a^4\,b+a^3\,b^2}-\frac {\left (\frac {\cos \left (c+d\,x\right )\,\left (13\,a^2\,b^3+20\,a\,b^4+8\,b^5\right )}{2\,\left (a^4+2\,a^3\,b+a^2\,b^2\right )}+\frac {\sqrt {b\,{\left (a+b\right )}^3}\,\left (\frac {4\,a^6\,b^2+6\,a^5\,b^3+2\,a^4\,b^4}{a^5+2\,a^4\,b+a^3\,b^2}-\frac {\cos \left (c+d\,x\right )\,\sqrt {b\,{\left (a+b\right )}^3}\,\left (3\,a+2\,b\right )\,\left (16\,a^7\,b^2+64\,a^6\,b^3+80\,a^5\,b^4+32\,a^4\,b^5\right )}{8\,\left (a^4+2\,a^3\,b+a^2\,b^2\right )\,\left (a^5+3\,a^4\,b+3\,a^3\,b^2+a^2\,b^3\right )}\right )\,\left (3\,a+2\,b\right )}{4\,\left (a^5+3\,a^4\,b+3\,a^3\,b^2+a^2\,b^3\right )}\right )\,\sqrt {b\,{\left (a+b\right )}^3}\,\left (3\,a+2\,b\right )}{4\,\left (a^5+3\,a^4\,b+3\,a^3\,b^2+a^2\,b^3\right )}+\frac {\left (\frac {\cos \left (c+d\,x\right )\,\left (13\,a^2\,b^3+20\,a\,b^4+8\,b^5\right )}{2\,\left (a^4+2\,a^3\,b+a^2\,b^2\right )}-\frac {\sqrt {b\,{\left (a+b\right )}^3}\,\left (\frac {4\,a^6\,b^2+6\,a^5\,b^3+2\,a^4\,b^4}{a^5+2\,a^4\,b+a^3\,b^2}+\frac {\cos \left (c+d\,x\right )\,\sqrt {b\,{\left (a+b\right )}^3}\,\left (3\,a+2\,b\right )\,\left (16\,a^7\,b^2+64\,a^6\,b^3+80\,a^5\,b^4+32\,a^4\,b^5\right )}{8\,\left (a^4+2\,a^3\,b+a^2\,b^2\right )\,\left (a^5+3\,a^4\,b+3\,a^3\,b^2+a^2\,b^3\right )}\right )\,\left (3\,a+2\,b\right )}{4\,\left (a^5+3\,a^4\,b+3\,a^3\,b^2+a^2\,b^3\right )}\right )\,\sqrt {b\,{\left (a+b\right )}^3}\,\left (3\,a+2\,b\right )}{4\,\left (a^5+3\,a^4\,b+3\,a^3\,b^2+a^2\,b^3\right )}}\right )\,\sqrt {b\,{\left (a+b\right )}^3}\,\left (3\,a+2\,b\right )\,1{}\mathrm {i}}{2\,d\,\left (a^5+3\,a^4\,b+3\,a^3\,b^2+a^2\,b^3\right )} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________